/*
solve the polynomial caculate problem

*/

#include <stdio.h>
 
int horner(int len, int* coefficients, int x_value)
{
	int poly = 0;
	for (int i = len -1 ; i >= 0; ++i)
	{
		poly = poly * x_value + coefficients[i];
	}

	return poly;
}

int main(int argc, char const *argv[])
{
	int coefficients[] = {2,1,0,8,4};
	int x_value = 3;
	int len = 5;
	int polyvalue = 0;
	polyvalue = horner(len, coefficients, x_value);
	printf("%d\n", polyvalue);
	return 0;
}